
<?php 
	if(isset($_POST['submit'])  && !isset($_SESSION['logined'])) 
	{
	$email=$_POST['email'];
	$matkhau=sha1($_POST['matkhau']);
	$matkhau1=sha1($_POST['matkhau1']);
	
	$tenkh=$_POST['tenkh'];
	$diachi=$_POST['diachi'];
	$dienthoai=$_POST['dienthoai'];
	if($_POST["matkhau"]==$_POST["matkhau1"] && $_POST["email"] !='' )//co phan biet chu hoa chu thuong
	//Ket noi den MySQL
	$con=mysql_connect("localhost","root","") or die("Khong the ket noi voi MySQL");
	

	//Chon CSDL QLSV
	mysql_select_db("clock",$con) or die("khong ket noi CSDL duoc");
	
	//Thuc hien cau truy van
	$query="INSERT INTO khachhang VALUES ('$email','$matkhau','$tenkh','$diachi','$dienthoai')";
	$result=mysql_query($query,$con);
	if($result) $tc=1; else $tc=0;
	} else header('Location:dangnhap.php');
?>

<script type="text/javascript">
if(<?php echo $tc;?>==1) {
	alert('Đăng ký thành công!');
	window.location='index.php';
	}
else if(<?php echo $tc;?>==0) {
	alert('Đăng ký không thành công!');
	history.back(); 
	}
</script>
